#include "esp32_base.h"
#include "esp32_pages.h"

#define PAGE_STACK_SIZE  10

typedef enum
{
    PAGE_NONE = 0,
    PAGE_Main,
    PAGE_Watch,
    PAGE_Window,
    PAGE_MAX
} Page_Type;

typedef struct{
    lv_obj_t * cont;
}AppGroup_T;

static AppGroup_T page_group[PAGE_MAX];
ESP32Manager manager;

#include "app_gui_all.h"

//================================================================
//================================================================
void ESP32Pages::init() {
    for(int i = 0; i < PAGE_MAX; i++) {
        page_group[i].cont = lv_obj_create(lv_scr_act());
        lv_obj_set_size(page_group[i].cont, 240, 240);
        lv_obj_center(page_group[i].cont);
    }
    manager.init(PAGE_MAX, PAGE_STACK_SIZE);
    manager.PageRegister(PAGE_Main, Setup1, NULL, Exit1, Event1);
    manager.PageRegister(PAGE_Watch, Setup2, NULL, Exit2, Event2);
    manager.PageRegister(PAGE_Window, Setup3, NULL, Exit3, Event2);
    manager.PagePush(PAGE_Main);
}

void ESP32Pages::key_proc(int key, int event) {
    manager.PageEventTransmit(key, event);
}

void ESP32Pages::routine() {
	manager.Running();
}
